<?php
/**
 * Created by JetBrains PhpStorm.
 * User: CAIXUDONG
 * Date: 11-6-16
 * Time: 下午4:06
 */
 
include '../bootstrap.php';

$_user = Model::getInstance('user');
$user_info = $_user->needLogin();

$cate_ids = $_input->post('cate_ids');
$role_id = $_input->post('role_id');

Model::getInstance('catehasrole')->delByRoleId($role_id);

if($cate_ids){
    $cate_ids = array_unique($cate_ids);
    foreach($cate_ids as $v){
        if($v){
            Model::getInstance('catehasrole')->add($v,$role_id);
        }
    }
}

$data = array(
    "statusCode"=>"200",
    "message"=>"权限设置成功!",
    "navTabId"=>"role",
);
echo Response::JSON($data);